import React, { Component } from 'react'
import Tab from './../../components/common/TabVertical'
import Content from './../../components/common/Content'
import Page from './../../components/common/Page'
import ask from '../../serve/api'
import './Project.css'

export default class Project extends Component {
  constructor(){
    super();
    this.state = {
      index : 0,
      tabs : [{
        name: '研究计划',
        contentData:{},
      },{
        name: '工作调研',
        contentData:{
          list : []
        },
      },{
        name: '内部课题',
        contentData:{},
      },{
        name: '对外课题',
        contentData:{},
      },{
        name: '委托课题',
        contentData:{},
      }],
    }
  }
  
  onTab(item, index) {
    this.setState({
      index,
    });
  }

  async fetchListLeader(){
    const { code, result } = await ask["listOrgLeader"]({
      page : 1,
      pageSize : 10,
    });
    try {
      if (code !== '000000') {
        throw new Error('数据出错');
      };
      
      const {tabs} = this.state;
      tabs[1].contentData.list = result;
      this.setState({
        index : 1,
        tabs,
      });

    } catch (error) {
      console.log(error);
    }
  }
  
  getCurrentPage() {

  }
  
  render() {
    const {
      index,
      tabs,
    } = this.state;

    return (
      <div className="company-project">
        <Tab tabs={tabs} onTab={index => this.onTab(index)} />
        <div className="project_content">
          <Content />
          <Page 
            pageConfig={{totalPage: 10}}
            pageCallbackFn={() => this.getCurrentPage()}
          />
        </div>
      </div>
    )
  }
}
